url = goloble_url
var app = new Vue({
	el: '#appDesktop',
	data: {
		//access_header:'',
		userList: [],
		userId: '',
		//url: 'http://114.215.83.227:809/admin/',
		userStatus: [{
				value: '1',
				label: '未认证'
			},
			{
				value: '2',
				label: '已认证'
			},
		],
		carState:'',
		statusUserId: '',
		
		UserSum: 0,
		carSum: 0,
		beginDate:'',
		endDate:'',
		beginTime:'',
		endTime:'',
		buttonState:false,
		list1: [{
			carNum:"请按条件查询数据...."
		}
		],
		//list2: [{}]
		
		
		
		

	},
	methods: {
		//时间戳转化
		timestampToTime(cjsj) {
			var date = new Date(date);
			var date = new Date(cjsj) //时间戳为10位需*1000，时间戳为13位的话不需乘1000
			var Y = date.getFullYear() + '-'
			var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
			var D = date.getDate() + ' '
			var h = date.getHours() + ':'
			var m = date.getMinutes() + ':'
			var s = date.getSeconds()
			return Y + M + D + h + m + s
			//console.log(timestampToTime(1533293827000))
		},
		
		
		//转化成标准时间格式
		transformTime(date){
			var date = new Date(date);
			 var y = date.getFullYear();  
			    var m = date.getMonth() + 1;  
			    m = m < 10 ? '0' + m : m;  
			    var d = date.getDate();  
			    d = d < 10 ? ('0' + d) : d;  
			    return y + '-' + m + '-' + d; 
		},


		//获取总的用户数量
		getUserSum() {

			//sessionStorage.removeItem("status");
			var vm = this;
			var access_header = 'a' + sessionStorage.getItem("token"); //获取数据token
			this.$http.post(url + 'adminGetUserCount', {

			}, {
				emulateJSON: true,
				headers: {
					'access_header': access_header
				}


			}).then(function(res) {
				if (res.data.status == 1) {
					// console.log("ssss" + res.data.message.countIsState)
					vm.UserSum = res.data.message.countIsState
					if (vm.UserSum == 0)
						vm.UserSum = '获取失败'



				} else if (res.data.status == 0) {

					vm.$Message.error('登录失效，3秒后强制登录....')
					
					
					setTimeout(() => {
						
					window.top.location="login.html" 
					},3000)
					
					
				} else {
					vm.$Message.error('不可预知错误')
				}

			}, function(res) {
				vm.$Message.error('不可预知错误,联系管理员')
			});
		},
		//获取总的车辆数量
		getCarSum() {
			var vm = this;

			var access_header = 'a' + sessionStorage.getItem("token"); //获取数据token
			this.$http.post(url + 'adminGetCarCount', {

			}, {
				emulateJSON: true,
				headers: {
					'access_header': access_header
				}


			}).then(function(res) {
				if (res.data.status == 1) {
					// console.log("ssss" + res.data.message.countIsState)
					vm.carSum = res.data.message.countIsState
					if (vm.carSum == 0)
						vm.carSum = "获取失败"



				} else if (res.data.status == 0) {

					// vm.$Message.error('获取失败，请重新登录')

				} else {
					vm.$Message.error('不可预知错误')
				}

			}, function(res) {
				vm.$Message.error('不可预知错误,联系管理员')
			});
			
			
			
			
		},
		
// // 通过起止时间、审核状态获取时间段内新增车辆列表
ByDateCarList() {
	var vm = this;
	
	if(vm.beginDate.length == 0 || vm.endDate.length == 0 || vm.beginTime.length == 0 || vm.endTime.length == 0){
		vm.$Message.error('请填写必选项')
	}else{
		// vm.$Message.error('ok')
		console.log('beginDate：'+this.transformTime(vm.beginDate))
		console.log('endDate：'+vm.endDate)
		console.log('beginTime：'+vm.beginTime)
		console.log('endTime：'+vm.endTime)
		
		vm.beginDate = this.transformTime(vm.beginDate)
		vm.endDate = this.transformTime(vm.endDate)
		
		
		var AllBeginDate = vm.beginDate +" "+vm.beginTime
		var AllEndDate = vm.endDate +" "+vm.endTime
		
		console.log('AllBeginDate：'+AllBeginDate)
		
	
		var access_header = 'a' + sessionStorage.getItem("token"); //获取数据token
		this.$http.post(url + 'adminGetNewAddCarListByBeginTimeEndTime', {
			beginTime:AllBeginDate,
			endTime:AllEndDate,
			carState:vm.carState,
			'currentPageNo': 1
			
		}, {
			emulateJSON: true,
			headers: {
				'access_header': access_header
			}
		
		
		}).then(function(res) {
			if (res.data.status == 1) {
				
				for (var i = 0; i < res.data.message.length; i++) {
					vm.list1 = res.data.message
					
					
					
				}
				//console.log("res.data.message[i]：" + res.data.message[2])
				//console.log("vm.list1[i].carNum：" + vm.list1[2].carNum)

			} else if (res.data.status == 0) {
		
				// vm.$Message.error('获取失败，请重新登录')
		
			} else {
				vm.$Message.error('不可预知错误')
			}
		
		}, function(res) {
			vm.$Message.error('不可预知错误,联系管理员')
		});
	}


		},
	},
	mounted() {
		this.getUserSum()
		this.getCarSum()
	},
	created() {


	},
	watch: {

	}


});
